<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	    <link rel="stylesheet" type="text/css" href="../css/mui.css"/>
	    <link rel="stylesheet" type="text/css" href="../css/iconfont.css"/>
	    <link rel="stylesheet" type="text/css" href="../css/index.css"/>
	    <script src="../js/jquery-1.9.1.min.js"></script>
		<title></title>
	</head>
	<body>
	</body>
	<script src="../js/mui.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		mui.init();
		mui.plusReady(function() {
			var self = plus.webview.currentWebview();
			var newurl=self.id;
			var baiduWV = plus.webview.create(newurl, "wangzhi", {
				top: "0",
				bottom: 0
			});
			self.append(baiduWV);
			//添加newId自定义事件监听
			
			/**
			 * 重写mui.back()方法
			 * http://dev.dcloud.net.cn/mui/window/#closewindow
			 */
			/**
			 * 监听子窗口对象是否可后退
			 * http://www.html5plus.org/doc/zh_cn/webview.html#plus.webview.WebviewObject.canBack
			 */
			document.getElementById("go_back").addEventListener("tap", function() {
				baiduWV.canBack(function(event) {
					var canBack = event.canBack;
					if(canBack) {
						baiduWV.back();
					} else {
						alert("到头了，不能后退了！");
					}
				});
			});

			// 右上角前进icon的事件
			document.getElementById("go_forward").addEventListener("tap", function() {
				/**
				 * 监听子窗口对象是否可前进
				 * http://www.html5plus.org/doc/zh_cn/webview.html#plus.webview.WebviewObject.canForward
				 */
				baiduWV.canForward(function(event) {
					var canForward = event.canForward;
					if(canForward) {
						baiduWV.forward();
					} else {
						alert("不能前进！");
					}
				});
			});
		});
	</script>
</html>
